package main

import (
	"fmt"
	"math"
)

// User /** 匿名字段你
type User struct {
	string
	byte
	int8
	float64
}

type Address struct {
	city string
}

type Person struct {
	name    string
	address *Address
}

type School struct {
	address string
}

type Student1 struct {
	name string
	School
}

func main() {

	//匿名函数
	big := func(num1, num2 float64) float64 {
		return math.Max(num1, num2)
	}(3, 5)
	fmt.Println(" big == ", big)
	t1 := struct {
		name, school string
	}{"go", "威信一中"}
	fmt.Println("t1.name ", t1.name)

	user := User{"GO", 'm', 3, 177.5}
	fmt.Printf("姓名 %s \n", user.string)
	fmt.Printf("性别 %c \n", user.byte)
	fmt.Printf("年龄 %d \n", user.int8)
	fmt.Printf("身高 %.2f \n", user.float64)

	//结构体嵌套
	address1 := Address{"成都"}
	//第1种赋值方式
	person1 := Person{"万祥", &address1}
	person2 := Person{"万祥", &Address{"成都"}}
	fmt.Println("person1.address == ", person1.address, "  person1.address == ", person2.address)
	fmt.Println("person1.address == ", person1.address.city, "  person1.address == ", person2.address.city)

	// 结构体嵌套模拟继承关系
	student1 := Student1{"万祥", School{"威信一中"}}
	fmt.Println(" 学校名字是  ", student1.School.address, student1.address)
	student2 := Student1{}
	student2.name = "万祥"
	student2.address = "威信一中"
	fmt.Println(" 学校名字是  ", student2.School.address, student2.address)

}
